export function getBase64ImageUrl(imgUrl) {
  function getBase64Image(img, width, height) { // width、height调用时传入具体像素值，控制大小 ,不传则默认图像大小
    var canvas = document.createElement('canvas');
    canvas.width = width || img.width;
    canvas.height = height || img.height;

    var ctx = canvas.getContext('2d');
    ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
    var dataURL = canvas.toDataURL();
    return dataURL;
  }
  var image = new Image();
  image.crossOrigin = '';
  image.src = imgUrl;
  return new Promise(function(resolve, reject) {
    if (imgUrl) {
      image.onload = function() {
        resolve(getBase64Image(image));
      }
    } else {
      reject('图片路径不能为空');
    }
  });
}
